package com.wash.shoes.common.enums;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 工厂状态 :STOP 暂停营业，NORMAL 正常营业  用枚举维护
 */
@Getter
@AllArgsConstructor
public enum FactoryStatusEnum {
    STOP("STOP", "暂停营业"), NORMAL("NORMAL", "正常营业");
    @EnumValue
    private String code;
    @JsonValue
    private String name;


    /**
     * 根据code获取枚举
     *
     * @param code code值
     * @return
     */
    @JsonCreator
    public static FactoryStatusEnum getEnumByCode(String code) {
        Assert.notNull(code, "code不能为空");
        for (FactoryStatusEnum c : FactoryStatusEnum.values()) {
            if (c.getCode().equals(code)) {
                return c;
            }
        }
        return null;
    }
}